package com.benyi.byiee.rest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.benyi.byiee.model.db.EnterpriseInfo;
import com.benyi.byiee.service.EnterpriseService;
import com.benyi.util.JsonResult;
import com.benyi.util.bean.Page;
import com.benyi.util.bean.PageReq;
import com.benyi.util.bean.ServiceException;


@RestController
@RequestMapping("/etp")
public class EnterpriseRest {
	private static Logger log = LoggerFactory.getLogger(EnterpriseRest.class);
	
	@Autowired
	private EnterpriseService epService;
	
	
	@RequestMapping(value = "/ks", method = RequestMethod.POST,consumes = {"application/json"})
	public JsonResult<Page<EnterpriseInfo>> queryByKeys(@RequestBody PageReq<String> req){ 
		JsonResult<Page<EnterpriseInfo>> ret; 
		try {
			Page<EnterpriseInfo> page = epService.queryByKeys(req);
			ret = JsonResult.success(page, "sucess"); 
		}catch(ServiceException e) {
			ret =JsonResult.fail(e.getErrorCode() , e.getMessage());
		}
		return ret;
	}
	
}
